import { RequestData } from "@ant-design/pro-table";
import { DeviceIdentifyItem } from "./types";
import { request } from "umi";
import { message } from "antd";
import { SUCCESS_CODE } from "@/utils/request";

//获取设备识别结果数据
export async function getIdentifyDataList(params: {
    tenant_id?: string,
    device_no?: string,
    space_name?: string,
    road_id?: string,
    page?: number,
    pageSize?: number,
}): Promise<RequestData<DeviceIdentifyItem>> {
    const res = await request('/device_identify_data/view', {
        params: {
            page: 1,
            pageSize: 10,
            ...params,
        },
    });
    if (!res || res.code !== SUCCESS_CODE) {
        message.error('获取失败');
        return { success: false, total: 0, data: [] };
    }
    return {
        success: true,
        total: res.data.total,
        data: res.data.list,
    };
}